package org.university.entity;

import io.swagger.annotations.ApiModelProperty;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.university.enums.GlobalEnums;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @TableName course
 */
@Entity
@Table(name = "course")
@Data
public class Course implements Serializable {

    @Id
    @NotBlank(message = "[]不能为空")
    @Size(max = 20, message = "编码长度不能超过20")
    @ApiModelProperty("")
    @Length(max = 20, message = "编码长度不能超过20")
    private String courseId;
    /**
     * 课程名
     */
    @NotBlank(message = "[课程名]不能为空")
    @Size(max = 100, message = "编码长度不能超过100")
    @ApiModelProperty("课程名")
    @Length(max = 100, message = "编码长度不能超过100")
    private String courseName;
    /**
     * 学分
     */
    @NotNull(message = "[学分]不能为空")
    @ApiModelProperty("学分")
    private BigDecimal credit;
    /**
     * 学时
     */
    @NotNull(message = "[学时]不能为空")
    @ApiModelProperty("学时")
    private Integer hours;
    /**
     * 课程类型
     */
    @NotNull(message = "[课程类型]不能为空")
    @ApiModelProperty("课程类型")
    @Enumerated(EnumType.STRING)
    private GlobalEnums.CourseType courseType;
    /**
     * 描述
     */
    @Size(max = 100, message = "编码长度不能超过100")
    @ApiModelProperty("描述")
    @Length(max = 100, message = "编码长度不能超过100")
    private String description;

    @Column(name = "deleted", columnDefinition = "tinyint(1) default 0")
    @ApiModelProperty("是否已删除")
    private Integer deleted = 0;
}
